package java6703.lesson11;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JDBCDemo6703 {
    private static final String DRIVER = "org.sqlite.JDBC";
    private static final String URL = "jdbc:sqlite:db6703.db3";
    private static final String USER = "";
    private static final String PW = "";

    public static void main(String[] args) throws SQLException, ClassNotFoundException {

        //加载并注册数据库驱动
        Class.forName(DRIVER);

        //连接数据库
        Connection conn = DriverManager.getConnection(URL, USER, PW);

        //调用连接对象的getMetaData().getDatabaseProductName()返回数据库名称
        System.out.println("使用的数据库产品："+conn.getMetaData().getDatabaseProductName());

        //调用连接对象的getMetaData().getDatabaseProductVersion()返回数据库版本号
        System.out.println("版本号："+conn.getMetaData().getDatabaseProductVersion());

        //调用连接对象的conn.getMetaData().getURL()返回数据库的URL
        System.out.println("数据库的URL："+conn.getMetaData().getURL());
    }
}